package com.hong.chapter8;

/**
 * 死锁测试
 *
 * 运行后
 *
 * 一、打开cmd
 * 输入jps
 *
 * 然后查看指定的线程比如：DeadLockTest
 *
 * 然后jstask xxx
 *
 * 就可以查询相关的死锁
 *
 */
public class DeadLockTest {

    public static void main(String[] args) {
        OtherService otherService = new OtherService();
        DeadLock deadLock = new DeadLock(otherService);
        otherService.setDeadLock(deadLock);
        new Thread(){
            @Override
            public void run() {
                while (true){
                    deadLock.m1();
                }
            }
        }.start();

        new Thread(){
            @Override
            public void run() {
                while (true){
                    otherService.s2();
                }
            }
        }.start();

    }
}
